import {ApolloClient} from 'apollo-client';
import {HttpLink} from 'apollo-link-http';
import fetch from 'node-fetch';
import {InMemoryCache} from 'apollo-cache-inmemory';

let gateway: ApolloClient<any> = null;

export function initGateway(uri): void {
  gateway = new ApolloClient({
    link: <any>new HttpLink({uri, fetch}),
    cache: new InMemoryCache()
  });
}

export function getGateway(): ApolloClient<any> {
  return gateway;
}
